package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.pojo.TonguePojo;
import com.medvalley.tcm.service.IDiagnosisDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "舌像接口")
@RestController
public class TongueController extends BaseController {

    @Autowired
    private IDiagnosisDataService diagnosisDataService;

    @ApiOperation(value = "上传舌像数据")
    @RequestMapping(value = "/tongue/save", method = RequestMethod.POST)
    public Result saveTongue(@ModelAttribute TonguePojo tonguePojo) {
        diagnosisDataService.saveTongue(tonguePojo);
        return success("", tonguePojo);
    }

    @ApiOperation(value = "根据id获取单个数据")
    @RequestMapping(value = "/tongue/get", method = RequestMethod.POST)
    public Result getTongue(@RequestParam long id) {
        TonguePojo tonguePojo = diagnosisDataService.getTongueById(id);
        return success("", tonguePojo);
    }

    @ApiOperation(value = "根据id获取单个数据")
    @RequestMapping(value = "/tongue/update", method = RequestMethod.POST)
    public Result updateTongue(@ModelAttribute TonguePojo tonguePojo ){
        diagnosisDataService.updateTongue(tonguePojo);
        return success("更新成功", tonguePojo);
    }

}
